fix: replace bare except with specific Exception handler in K8s client init#1300
Open
v0idheaven wants to merge 3 commits into
Open
fix: replace bare except with specific Exception handler in K8s client init#1300v0idheaven wants to merge 3 commits into
v0idheaven wants to merge 3 commits into
Conversation
Review Summary by QodoReplace bare except with specific Exception handler in K8s client init
WalkthroughsDescription• Replace bare except clause with specific Exception handler • Add clear error logging with kubeconfig path and exception details • Return -1 to exit gracefully instead of continuing with undefined kubecli • Remove no-op kubeconfig_path bare expression statement Diagramflowchart LR
A["Bare except clause<br/>catches all exceptions"] -->|"Replace with"| B["except Exception as e"]
B -->|"Log error with"| C["kubeconfig path<br/>and exception details"]
C -->|"Exit gracefully"| D["return -1"]
E["Remove no-op<br/>kubeconfig_path statement"] -->|"Cleanup"| D
File Changes1. run_kraken.py
|
Code Review by Qodo
1.
|
…t init The bare except: clause in run_kraken.py silently swallowed all exceptions during Kubernetes client initialization, including KeyboardInterrupt and SystemExit. This made failures invisible and caused confusing secondary errors (NameError on kubecli) later in the run. Changes: - Remove bare except: and replace with except Exception as e: - Log a clear error message with the kubeconfig path and exception - Return -1 to exit gracefully instead of continuing with an undefined kubecli reference - Remove the no-op kubeconfig_path bare expression statement Fixes krkn-chaos#1298 Signed-off-by: v0idheaven <dahiyavarun2007@gmail.com>
- Switch to logging.exception() so the full stack trace is preserved - Use return 1 instead of -1 to match standardized exit codes - Log message now includes the exit code for observability Signed-off-by: v0idheaven <dahiyavarun2007@gmail.com>
17b425e to
4f0f62c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1298
The bare except: block in
un_kraken.py around line 231 was silently swallowing everything — including KeyboardInterrupt and SystemExit. Worse, if KrknKubernetes() failed before kubecli was assigned, the except block itself would throw a NameError that also disappeared silently. Bad kubeconfig, zero feedback, confusing crash later.
Replaced it with except Exception:, added logging.exception() with the kubeconfig path, and return 1 on failure. Also removed the no-op bare kubeconfig_path expression that was doing nothing.
Tested by pointing config at a nonexistent kubeconfig path — logs the error clearly and exits cleanly.